﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NCalculator.Operations
{
    [Serializable()]
    public class ValueNode : Node
    {
        #region Attributes
        protected double _value;
        #endregion

        public ValueNode()
        {
            _value = 0;
        }

        public ValueNode(double value)
        {
            _value = value;
        }

        /// <summary>
        /// Evaluatuion of value 
        /// </summary>
        /// <returns>Returns value stored in</returns>
        public override double Evaluation()
        {
            return _value;
        }

        /// <summary>
        /// Get/Set value stored in node
        /// </summary>
        public double Value
        {
            get { return _value; }
            set
            {
                if (_value != value)
                    _value = value;
            }
        }

        /// <summary>
        /// Convert value into string
        /// </summary>
        /// <returns>Value converted into string</returns>
        public override string ToString()
        {
            return _value.ToString();
        }
    }
}
